﻿using System;
using System.Web.UI.WebControls;
using BLL;
using Model;

public partial class ProductPackage_CheckandPackage : System.Web.UI.Page
{
    PackageProduct pp;

    public ProductPackage_CheckandPackage()
    {
        pp = new PackageProduct();
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        
    }

    protected void Button2_Click(object sender, EventArgs e)
    {
        this.Label8.Visible = false;
        this.Image1.Visible = false;
        this.Image2.Visible = false;
        Package();
    }

    protected void DisplayAmountforPrint()
    {
        string productSN = this.TextBox1.Text.Trim();
        int amount = pp.GetCountforPrint(productSN);
        if (amount != 0)
        {
            this.Label8.Text = "此产品类型已包装未打印外箱标签的产品数量为 <B>" + amount.ToString() + "</B>";
            this.Label8.Visible = true;
        }
    }

    protected void Package()
    {
        string var_productSN = this.TextBox1.Text.Trim();
        string var_tag = this.TextBox2.Text.Trim();
        string var_outSN3BK = this.TextBox3.Text.Trim();
        string var_2DSN = this.TextBox4.Text.Trim();
        string packer = User.Identity.Name;
        string str;

        int i = pp.CheckandPackage(var_productSN, var_tag, var_outSN3BK, var_2DSN, packer, out str);
        if (i == 1)
        {
            //DisplayAmountforPrint();
            this.Image1.Visible = true;
            this.Image2.Visible = false;
            this.TextBox1.Text = "";
            this.TextBox2.Text = "";
        }
        else if (i == 2)
        {
            this.Image2.Visible = true;
            this.Image1.Visible = false;
        }
        ClientScript.RegisterStartupScript(ClientScript.GetType(), "", "<script>alert('" + str + "');</script>");
    }    
}
